#pragma once

#include "rfidlib.h"

#if __cplusplus
extern "C"
{
#endif



namespace RFIDLIB
{

/************************************functions not opened for application*******************************/
RFID_API RFID_DN_HANDLE RDR_CreateAccessNoneParamRequest(DWORD accessCode); // use

RFID_API err_t RDR_GetCapabilities(RFID_READER_HANDLE hr,
                                   BYTE Type,
                                   RFID_DN_HANDLE pCapabilityData /* out */
                                   );
RFID_API err_t RDR_SetConfig(RFID_READER_HANDLE hr,
                             RFID_DN_HANDLE  CfgItemSettingData /* Input, Node name is item name */
                             );
RFID_API err_t RDR_GetConfig(RFID_READER_HANDLE hr,
                             RFID_DN_HANDLE pCfgItemGettedData /*Output, Node name is item name*/
                             );
RFID_API err_t RDR_EnableAsyncTagReportOutput(RFID_READER_HANDLE hr, BYTE type, WIN_MSG_t msg, HWND hwnd, RFID_EVENT_CALLBACK cb);
RFID_API err_t RDR_DisableAsyncTagReportOutput(RFID_READER_HANDLE hr);
RFID_API err_t RDR_IsSupportInventoryAsyncOutput(RFID_READER_HANDLE hr, BOOLEAN *suppported);
RFID_API RFID_DN_HANDLE RDR_CreateSetGetConfigItemList();

/*********************************functions opened*****************************************************/

RFID_API DWORD HID_Enum();
RFID_API err_t HID_GetEnumItem(DWORD indx, BYTE infType, LPTSTR infBuffer, DWORD *nSize);
RFID_API DWORD COMPort_Enum(void);
RFID_API err_t COMPort_GetEnumItem(DWORD idx, LPTSTR nameBuf, DWORD nSize);
RFID_API DWORD NET_Enum(void);
RFID_API err_t NET_GetEnumItem(DWORD indx, BYTE infType, LPTSTR infBuffer, DWORD *nSize);

RFID_API err_t RDR_Open(LPCTSTR connStr, RFID_READER_HANDLE *hrOut);
RFID_API err_t RDR_Close(RFID_READER_HANDLE hr);
/*
    *create inventory parameter list node
    */
RFID_API RFID_DN_HANDLE RDR_CreateInvenParamSpecList();

RFID_API err_t RDR_SetAtennaAsUniqueIdentifier(RFID_DN_HANDLE InvenParamSpecList, BYTE flag);
/*
    *inventory, support multiple air protocol, embedded commands
    */
RFID_API err_t RDR_TagInventory(RFID_READER_HANDLE hr,
                                BYTE AIType,
                                BYTE AntennaCount,
                                BYTE AntennaIDs[],
                                RFID_DN_HANDLE InvenParamSpecList);
/*
    * 加入盘点写的命令
    */
RFID_API err_t RDR_AddTagAccessToInvenParam(RFID_DN_HANDLE hInvenParam, RFID_DN_HANDLE hTagAccess);
/*
    *  解析盘点写的结果
    */
RFID_API err_t RDR_ParseTagDataReportWriteResult(RFID_DN_HANDLE hTagReport, RFID_DN_HANDLE cmd, BYTE *result);
/*
    * 解析盘点读的数据块数据
    */
RFID_API err_t RDR_ParseTagDataReportBlockData(RFID_DN_HANDLE hTagReport, BYTE *buf, DWORD *nSize);
/*
    *get tag data report count
    */
RFID_API DWORD RDR_GetTagDataReportCount(RFID_READER_HANDLE hr);
/*
    *get tag data report
    */
RFID_API RFID_DN_HANDLE RDR_GetTagDataReport(RFID_READER_HANDLE hr, BYTE seek);
/*
    *connect tag
    */
RFID_API err_t RDR_TagConnect(RFID_READER_HANDLE hr,
                              RFID_DN_HANDLE ConnParms,   /* Connect parameters, inclue AIP id and tag id */
                              RFID_TAG_HANDLE *hTag   /* Return handle of the connected picc */
                              );
/*
    *access tag
    */
RFID_API err_t RDR_TagAccess(RFID_READER_HANDLE hr,
                             RFID_TAG_HANDLE hTag, 		/* the handle of connected picc */
                             RFID_DN_HANDLE tagAccess
                             );
/*
    *disconnect tag
    */
RFID_API err_t RDR_TagDisconnect(RFID_READER_HANDLE hr,
                                 RFID_TAG_HANDLE hTag);
/*
    *disconnect all connected tags
    */
RFID_API err_t RDR_DisconnectAllTags(RFID_READER_HANDLE hr);
/*
    * get connected tag information
    */
RFID_API err_t  RDR_GetConnectedTagInfo(RFID_READER_HANDLE hr, RFID_TAG_HANDLE hTag, BYTE infType, BYTE *infBuffer, DWORD *nSize);
/*
    *get reader last return error
    */
RFID_API err_t RDR_GetReaderLastReturnError(RFID_READER_HANDLE hr);

RFID_API err_t RDR_SetAcessAntenna(RFID_READER_HANDLE hr, BYTE AntennaID);

RFID_API err_t RDR_OpenRFTransmitter(RFID_READER_HANDLE hr);

RFID_API err_t RDR_CloseRFTransmitter(RFID_READER_HANDLE hr);

RFID_API err_t RDR_SetCommuImmeTimeout(RFID_READER_HANDLE hr);
RFID_API err_t RDR_ResetCommuImmeTimeout(RFID_READER_HANDLE hr);

RFID_API DWORD RDR_GetAntennaInterfaceCount(RFID_READER_HANDLE hr);

RFID_API err_t RDR_GetOutputCount(RFID_READER_HANDLE hr, BYTE *nCount);

RFID_API err_t RDR_GetOutputName(RFID_READER_HANDLE hr, BYTE idxOut, LPTSTR bufName, DWORD *nSize);

RFID_API RFID_DN_HANDLE RDR_CreateSetOutputOperations();

/*
    * outMode:
      0: No change
      1: On
      2: Off
      3: flash
    */
RFID_API err_t RDR_AddOneOutputOperation(RFID_DN_HANDLE hOperas, BYTE outNo, BYTE outMode, DWORD outFrequency, DWORD outActiveDuration, DWORD outInactiveDuration);

RFID_API err_t RDR_SetOutput(RFID_READER_HANDLE hr, RFID_DN_HANDLE outputOpers /* output operations */);

RFID_API err_t RDR_LoadFactoryDefault(RFID_READER_HANDLE hr);




RFID_API err_t RDR_SystemReset(RFID_READER_HANDLE hr);


RFID_API err_t RDR_GetReaderInfor(RFID_READER_HANDLE hr,
                                  BYTE Type,
                                  LPTSTR buffer,
                                  DWORD *nSize);

RFID_API err_t RDR_ConfigBlockWrite(RFID_READER_HANDLE hr, DWORD cfgno, BYTE cfgdata[], DWORD nSize, DWORD mask);
RFID_API err_t RDR_ConfigBlockRead(RFID_READER_HANDLE hr, DWORD cfgno, BYTE cfgbuff[], DWORD nSize);
RFID_API err_t RDR_ConfigBlockSave(RFID_READER_HANDLE hr, DWORD cfgno);

RFID_API err_t RDR_CreateRS485Node(RFID_READER_HANDLE hr, DWORD busAddr, RFID_READER_HANDLE *ohrRS485Node);

RFID_API err_t RDR_GetSupportedAirInterfaceProtocol(RFID_READER_HANDLE hr, DWORD index, DWORD *AIPType);

RFID_API err_t RDR_DetectNoise(RFID_READER_HANDLE hr, BYTE noiseData[], DWORD *nSize);

RFID_API err_t RDR_EnableProtocolLog(RFID_READER_HANDLE hr, BYTE methType, WIN_MSG_t msg, HWND hwnd, RFID_EVENT_CALLBACK_NEW cb, void *param);
RFID_API err_t RDR_DisalbeProtocolLog(RFID_READER_HANDLE hr);
RFID_API err_t RDR_GetGPICount(RFID_READER_HANDLE hr, DWORD *oCount);

RFID_API err_t RDR_ExeSpecialControlCmd(RFID_READER_HANDLE hr, RFID_DN_HANDLE hCtrlCmd);

RFID_API err_t RDR_GetGPIsStatus(RFID_READER_HANDLE hr/* in */,
                                 BYTE GPIs[]/* in */,
                                 WORD number /* in */,
                                 BYTE status[] /* out */);

RFID_API err_t RDR_SetEventHandler(RFID_READER_HANDLE hr, BYTE eventType, BYTE methType, UINT msg, HWND hwnd, RFID_EVENT_CALLBACK_NEW cb, VOID *param);
RFID_API err_t RDR_GetAirInterfaceProtName(RFID_READER_HANDLE hr, DWORD AIPType, LPTSTR namebuf, DWORD nSize);
RFID_API err_t RDR_LoadAuthKey(RFID_READER_HANDLE hr, BYTE storeType, BYTE keyType, BYTE key[], WORD keylen);
RFID_API err_t RDR_SelectAuthKey(RFID_READER_HANDLE hr, BYTE keyType);
RFID_API err_t RDR_CommandTransceive(RFID_READER_HANDLE hr, DWORD cmd, BYTE *prmDataSnd, DWORD bytesToSnd, BYTE *prmDataRecv, DWORD *bytesRecv, DWORD timeout);
RFID_API err_t RDR_StartBootLoader(RFID_READER_HANDLE hr);
RFID_API err_t RDR_UpdateHardSerialNum(RFID_READER_HANDLE hr, BYTE sernum[], WORD length);

RFID_API err_t RDR_UpdateHardProductNum(RFID_READER_HANDLE hr, BYTE pid[], WORD length);

RFID_API err_t RDR_ResetRF(RFID_READER_HANDLE hr);

RFID_API err_t DNODE_Destroy(RFID_DN_HANDLE dn);

RFID_API err_t RDR_SetInvenStopTrigger(RFID_DN_HANDLE hInvenParams, BYTE stopTriggerType, DWORD maxTimeout, DWORD triggerValue);

RFID_API err_t RDR_IsSupportEmbeddedTagAccess(RFID_READER_HANDLE hr, BOOLEAN *isSupported);

RFID_API DWORD Bluetooth_Enum();
RFID_API err_t Bluetooth_GetEnumItem(DWORD idx, BYTE infType, LPTSTR nameBuf, DWORD *nSize);

/*
    * 标示在关闭之前停止所有通行操作 ， 通信连接有可能会中断
    */
RFID_API err_t RDR_SetStopCommBeforeClose(RFID_READER_HANDLE hr);


RFID_API err_t  RDR_GetSystemTime(RFID_READER_HANDLE hr, DWORD *year, BYTE *month, BYTE *day, BYTE *hour, BYTE *minute, BYTE *second);
RFID_API err_t  RDR_SetSystemTime(RFID_READER_HANDLE hr, DWORD year, BYTE month, BYTE day, BYTE hour, BYTE minute, BYTE second);
RFID_API err_t RDR_BuffMode_FetchRecords(RFID_READER_HANDLE hr, DWORD flags);
RFID_API err_t RDR_BuffMode_ClearRecords(RFID_READER_HANDLE hr);
RFID_API err_t RDR_BuffMode_FlashEmpty(RFID_READER_HANDLE hr);

RFID_API err_t RDR_FetchTodayPassingData(RFID_READER_HANDLE hr, BYTE nFlag, BYTE nAddr);
RFID_API err_t RDR_FetchHistoryPassingData(RFID_READER_HANDLE hr, BYTE nFlag, BYTE nAddr);
RFID_API RFID_DN_HANDLE	RDR_GetTodayPassingReport(RFID_READER_HANDLE hr, BYTE seek);
RFID_API RFID_DN_HANDLE	RDR_GetHistoryPassingReport(RFID_READER_HANDLE hr, BYTE seek);
RFID_API err_t RDR_ParseTodayPassingReport(RFID_DN_HANDLE hReport, BYTE *mDirection, DWORD *mPassingValue, BYTE mTime[]);
RFID_API err_t RDR_ParseHistoryPassingReport(RFID_DN_HANDLE hReport, DWORD *mInValue, DWORD *mOutValue, BYTE mDate[]);

RFID_API err_t RDR_ResetBackupAntenna(RFID_READER_HANDLE hr);

RFID_API err_t  RDR_StartRO(RFID_READER_HANDLE hr, DWORD ROSepcID);
RFID_API err_t  RDR_StopRO(RFID_READER_HANDLE hr, DWORD ROSepcID);

RFID_API err_t  RDR_ParseTagDataReportRaw(RFID_DN_HANDLE hTagReport, BYTE rawBuffer[], DWORD *nSize);
RFID_API err_t  RDR_BuffMode_StartReportCollection(RFID_READER_HANDLE hr);
RFID_API err_t  RDR_BuffMode_StopReportCollection(RFID_READER_HANDLE hr);
RFID_API err_t  RDR_BuffMode_StopReportCollectionNoWait(RFID_READER_HANDLE hr);
RFID_API err_t  RDR_ResetPassingCounter(RFID_READER_HANDLE hr, DWORD flag);
RFID_API err_t  RDR_GetPassingCounter(RFID_READER_HANDLE hr, DWORD *inFlow, DWORD *outFlow);
RFID_API err_t  RDR_ChangePassingCounter(RFID_READER_HANDLE hr, BYTE addr, DWORD inFlow, DWORD outFlow);
RFID_API err_t  RDR_SetPassingCounter(RFID_READER_HANDLE hr, BYTE addr, DWORD inFlow, DWORD outFlow);
RFID_API err_t  RDR_ReverseInOutDirection(RFID_READER_HANDLE hr);
RFID_API err_t  RDR_Login(RFID_READER_HANDLE hr, BYTE pwd[]);
RFID_API err_t  RDR_EnablePasswordLogin(RFID_READER_HANDLE hr, BYTE pwd[], BOOLEAN enable);
RFID_API err_t  RDR_UpdateLoginPassword(RFID_READER_HANDLE hr, BYTE pwd[], BYTE newPwd[]);
RFID_API err_t  RDR_GetAIPTypeName(RFID_READER_HANDLE hr, DWORD AIP_ID, LPTSTR nameBuf, DWORD *nSize);
RFID_API err_t  RDR_GetTagTypeName(RFID_READER_HANDLE hr, DWORD AIP_ID, DWORD TAG_ID, LPTSTR nameBuf, DWORD *nSize);
RFID_API err_t  RDR_ResetTagFilterCounter(RFID_READER_HANDLE hr);
RFID_API err_t  RDR_TestWGIF(RFID_READER_HANDLE hr);

RFID_API err_t RDR_ModuleStartBootLoader(RFID_READER_HANDLE hr, LPCTSTR sDevId_Mode_Index);
RFID_API err_t RDR_ModuleStopBootLoader(RFID_READER_HANDLE hr, LPCTSTR sDevId_Mode_Index);
RFID_API err_t RDR_ModuleWrite(RFID_READER_HANDLE hr, BYTE transferData[], DWORD nTransferData);
RFID_API err_t RDR_ModuleRead(RFID_READER_HANDLE hr, DWORD timeout, BYTE dataBack[], DWORD *nDataBackSize);


RFID_API err_t RDR_GetIOPortIDs(RFID_READER_HANDLE hr, BYTE OutputIDs[], DWORD *OutputSize, BYTE InputIDs[], DWORD *InputSize);

RFID_API err_t RDR_DetectAntennaCount(RFID_READER_HANDLE hr, DWORD *mCount);
RFID_API err_t RDR_DiagnosisReader(RFID_READER_HANDLE hr, BYTE mode, DWORD *flag);
RFID_API err_t RDR_GetNoiseLevel(RFID_READER_HANDLE hr, BYTE AntennaID, WORD* min, WORD* avg, WORD* max);
RFID_API err_t RDR_GetNoiseLevelWithBase(RFID_READER_HANDLE hr, BYTE AntennaID, WORD * base, BYTE *count, WORD*data);

RFID_API err_t RDR_CheckAntennas(RFID_READER_HANDLE hr, BYTE option, BYTE AntennaCount, BYTE AntennaID[], BYTE sta[], DWORD swr[]);
RFID_API err_t RDR_AdjustAntenna(RFID_READER_HANDLE hr, BYTE antenna_id, WORD calib_imp);

RFID_API err_t RDR_CheckAntennasV2(RFID_READER_HANDLE hr, BYTE AntennaCount, BYTE AntennaID[], BYTE sta[], DWORD swr[]);

RFID_API err_t RDR_GetReaderDetailInfor(RFID_READER_HANDLE hr, WORD info_s, RFID_DN_HANDLE *Detail);
RFID_API err_t RDR_ParseReaderDetailBasic(RFID_DN_HANDLE report, BYTE product[]/*3 bytes*/, BYTE firmware[]/*2 bytes*/, BYTE hardware[]/*2 bytes*/, BYTE serial[]/*5 bytes*/);
RFID_API err_t RDR_ParseReaderDetailAntennaCount(RFID_DN_HANDLE report, BYTE* mAntennaCount);
RFID_API err_t RDR_ParseReaderDetailIO(RFID_DN_HANDLE report, BYTE input_ids[], BYTE *input_size, BYTE output_ids[], BYTE *output_size);
RFID_API err_t RDR_ParseReaderDetailMuxCount(RFID_DN_HANDLE report, BYTE *muxCount);
RFID_API err_t RDR_ParseReaderDetailMuxInfo(RFID_DN_HANDLE report, DWORD index, BYTE *addr, BYTE*ports, WORD* firmware, BYTE*sta);
RFID_API err_t RDR_ParseReaderDetailComm(RFID_DN_HANDLE report, WORD* comm);
RFID_API err_t RDR_DetectMux(RFID_READER_HANDLE hr, BYTE *cnt);
RFID_API err_t RDR_GetInputStatus(RFID_READER_HANDLE hr, BYTE InputIO[], BYTE Status[], DWORD *nSize);
RFID_API err_t RDR_SetFactoryInfor(RFID_READER_HANDLE hr, BYTE opt, BYTE pwd[], BYTE sn[]);
RFID_API err_t RDR_DetectOutputCount(RFID_READER_HANDLE hr, DWORD *mCount);
RFID_API err_t RDR_RFTransmitterOperate(RFID_READER_HANDLE hr, BYTE opt, BYTE ant);

RFID_API err_t RDR_ConfigBlockLock(RFID_READER_HANDLE hr, BYTE pwb[], DWORD cfgno, DWORD mask, DWORD lock);
RFID_API err_t RDR_ConfigBlockLockState(RFID_READER_HANDLE hr, DWORD cfgno, DWORD *sta);
RFID_API err_t RDR_SetMultiAccessAntennas(RFID_READER_HANDLE hr, BYTE antennas[], BYTE nSize);

RFID_API err_t RDR_AccessMultipleTags(RFID_READER_HANDLE hr, RFID_DN_HANDLE hTagSet);
RFID_API RFID_DN_HANDLE CreateMultipleAccessTagSet(BYTE bDefaultAnt, BYTE bAllAnt, BYTE bAntDelay, DWORD mAntDelayTime);
RFID_API err_t RDR_SetLastATagTagType(RFID_DN_HANDLE hTagSet, DWORD tagType);
RFID_API err_t RDR_SetLastATagAntennas(RFID_DN_HANDLE hTagSet, BYTE pAnt[], BYTE antCnt);
RFID_API err_t RDR_AddLastATagAccessCommand(RFID_DN_HANDLE hTagSet, RFID_DN_HANDLE hCommand);
RFID_API err_t RDR_SeekAccessTag(RFID_DN_HANDLE hTagSet, WORD idx);
RFID_API RFID_DN_HANDLE RDR_GetTagAccessCommand(RFID_DN_HANDLE hTagSet, BYTE seekType);

RFID_API err_t RDR_FridgeInventory(RFID_READER_HANDLE hr, BYTE mode, BYTE mask);
RFID_API err_t RDR_FridgeParseTagDataReport(RFID_DN_HANDLE hTagReport,
                                            BYTE *tag_sta,
                                            BYTE* ant_id,
                                            BYTE *tag_data,
                                            BYTE *nSize);
RFID_API RFID_DN_HANDLE RDR_CreateDownloadTagsOperations();
RFID_API err_t RDR_AddOneDownloadTagOperation(RFID_DN_HANDLE hOperas, BYTE uid[], BYTE uidlen, BYTE ant);
RFID_API err_t RDR_FridgeDownloadTag(RFID_READER_HANDLE hr, RFID_DN_HANDLE hOperas, BYTE mode);


RFID_API err_t RDR_SearchLSG(RFID_READER_HANDLE hr);//搜索安全门

RFID_API err_t RDR_ClearHistoryRecord(RFID_READER_HANDLE hr);//清除历史记录
RFID_API err_t RDR_ClearTodayRecord(RFID_READER_HANDLE hr);//清除实时记录

RFID_API err_t RDR_SaveSearchLSG(RFID_READER_HANDLE hr);//开始搜索安全门

RFID_API err_t RDR_GetSingleDoorInfo(RFID_READER_HANDLE hr, BYTE sid, LPTSTR buffer, DWORD *nSize);//获取单片门信息
RFID_API err_t RDR_GetSingleDoorSubModuleInfo(RFID_READER_HANDLE hr, BYTE sid, BYTE sub_mcu_id, LPTSTR buffer, DWORD *nSize);//获取单片门子模块信息
RFID_API err_t RDR_GetSingleDoorSWR(RFID_READER_HANDLE hr, BYTE sid, BYTE antennnaCnt, BYTE * ant, WORD *swr);//获取单片门驻波

//RFID_API err_t RDR_GetSingleDoorSWRReport(RFID_READER_HANDLE hr, BYTE sid, BYTE aid, WORD * aswr);

RFID_API err_t RDR_GetSingleDoorTemp(RFID_READER_HANDLE hr, BYTE sid, DWORD * temp);//获取单片门温度
RFID_API err_t RDR_GetSingleDoorRFIDPower(RFID_READER_HANDLE hr, BYTE sid, DWORD * power);//获取单片门射频功率
RFID_API err_t RDR_GetSingleDoorNoiseLevel(RFID_READER_HANDLE hr, BYTE sid, BYTE antennaCnt, BYTE * aid, DWORD* NOI_MIN, DWORD *NOI_AVG, DWORD *NOI_MAX);//获取单片门噪声
//RFID_API err_t RDR_GetSingleDoorNosieLevelReport(RFID_READER_HANDLE hr, BYTE sid, BYTE aid, DWORD* NOI_MIN, DWORD *NOI_AVG, DWORD *NOI_MAX);


RFID_API err_t RDR_GetSingleDoorSysErr(RFID_READER_HANDLE hr, BYTE sid, DWORD *mcErrFlag);//获取单片安全门的系统错误
RFID_API err_t RDR_GetSingleDoorOutput(RFID_READER_HANDLE hr, BYTE sid, BYTE *TE, BYTE * FRQ, DWORD * ACTIVE, DWORD *DEACTIVE, DWORD mask);
RFID_API err_t RDR_GetSingleDoorMos(RFID_READER_HANDLE hr, BYTE sid, BYTE *TE, BYTE * FRQ, DWORD * ACTIVE, DWORD *DEACTIVE);

RFID_API err_t RDR_SetSingleDoorOutput(RFID_READER_HANDLE hr, BYTE sid, BYTE *TE, BYTE *FRQ, DWORD *ACTIVE, DWORD *DEACTIVE, DWORD mask, BOOL bsave);//写入 单门输出端口联动方式 配置
RFID_API err_t RDR_SetSingleDoorMos(RFID_READER_HANDLE hr, BYTE sid, BYTE *TE, BYTE  *FRQ, DWORD  *ACTIVE, DWORD *DEACTIVE);

RFID_API err_t RDR_GetLSGSearchReport(RFID_READER_HANDLE hr, BYTE * sta);//搜索单门
RFID_API RFID_DN_HANDLE RDR_FetchLSGSearchReport(RFID_READER_HANDLE hr, BYTE seek);//获取单门搜索的一片门的句柄
RFID_API err_t RDR_ParseLSGSearchReport(RFID_DN_HANDLE hd, BYTE *sid, BYTE *type, BYTE * gid, BYTE * gidLength);//解析单门搜索信息

RFID_API err_t RDR_ParseLSGWarnningReport(RFID_DN_HANDLE hd, BYTE *sid, BYTE * eventtype, BYTE * direction, BYTE * rawData, DWORD * size);

RFID_API err_t RDR_GetSingleDoorOnlineStatus(RFID_READER_HANDLE hr, BYTE *num, BYTE *SID, BYTE *TYPE, BYTE *gid, BYTE *gidlength, BYTE *STA);//获取单门在线状态

RFID_API err_t RDR_ResetSingleDoor(RFID_READER_HANDLE hr, BYTE sid);//重启安全门
RFID_API err_t RDR_SingleDoorAVAlarm(RFID_READER_HANDLE hr, BYTE sid);//单片安全门声光报警
RFID_API err_t RDR_StopAntiTheft(RFID_READER_HANDLE hr);//停止安全门防盗
RFID_API err_t RDR_ResumeAntiTheft(RFID_READER_HANDLE hr);//恢复安全门防盗

/**测试工具用到的接口*/
RFID_API err_t RDR_DeviceDebugAntTest(RFID_READER_HANDLE hr, BYTE *data, BYTE nSize);
RFID_API err_t RDR_DeviceDebugBeepTest(RFID_READER_HANDLE hr, BYTE type);
RFID_API err_t RDR_DeviceDebugLedOrOutput(RFID_READER_HANDLE hr, BYTE  time, BYTE frq, BOOL ledOrOutput/*false:led ture:output*/);
RFID_API err_t RDR_DeviceDebugRFIDPower(RFID_READER_HANDLE hr, BYTE pwr);
RFID_API err_t RDR_AntSel(RFID_READER_HANDLE hr, BYTE ant, BYTE dc);
RFID_API err_t RDR_InputSelect(RFID_READER_HANDLE hr, BYTE port);
RFID_API err_t RDR_DeviceDebugAlarmOut(RFID_READER_HANDLE hr, BYTE OPT);
RFID_API err_t RDR_DeviceDebugAntCheck(RFID_READER_HANDLE hr, BYTE option, BYTE *num, BYTE *id, WORD *swr);
RFID_API err_t RDR_DeviceDebugGetDiagnosisData(RFID_READER_HANDLE hr, WORD flag, WORD * temp, WORD * rfpwr, DWORD * sysErr);



/**LSG428 618 拓展的记录查询接口***/
RFID_API err_t RDR_GetLSGRecord(RFID_READER_HANDLE hr, BYTE option, BYTE flag);
RFID_API err_t RDR_ParseHistoryPassingReport_V2(RFID_DN_HANDLE hReport, DWORD *mInValue, DWORD *mOutValue, BYTE mDate[]);
RFID_API err_t RDR_ParseTodayPassingReport_V2(RFID_DN_HANDLE hReport, BYTE *mDirection, DWORD *mPassingValue, BYTE mTime[]);
RFID_API err_t LSG_SetOutput(RFID_READER_HANDLE hr, BYTE sid, RFID_DN_HANDLE outputOpers /* output operations */);
RFID_API err_t RDR_GetPassingCounter_V2(RFID_READER_HANDLE hr, DWORD *inFlow, DWORD *outFlow);
RFID_API err_t RDR_ParseTagDataReportRaw_V2(RFID_DN_HANDLE hTagReport, BYTE rawBuffer[], DWORD *nSize);


RFID_API err_t RDR_GetAlarmEventType(RFID_READER_HANDLE hr, BYTE type, LPTSTR buffer, DWORD *nSize);

//RFID_API err_t LSG_FetchStoredDataAndAlaramFromGate(RFID_READER_HANDLE hr, BOOLEAN del, DWORD additional, BYTE gid, DWORD *pcIN, DWORD * pcOUT);

RFID_API err_t LSG_FetchStoredDataAndAlaramFromGate(RFID_READER_HANDLE hr, BOOLEAN del, DWORD additional, BYTE gid, DWORD*pcInTotal, DWORD*pcOutTotal, DWORD*pcInDay, DWORD*pcOutDay);

RFID_API DWORD   LSG_GetBufRecordCount(RFID_READER_HANDLE hr, BYTE type);
RFID_API RFID_DN_HANDLE   LSG_ReadBufRecord(RFID_READER_HANDLE hr, BYTE seek, BYTE type);
RFID_API err_t  LSG_ParseAlaramRecord(RFID_DN_HANDLE hTagReport, BYTE *sid, BYTE *date, BYTE *event, BYTE  *dFla, BYTE *uid, DWORD *uSize, BYTE *user, DWORD *userSize);
RFID_API err_t  LSG_ParseDayPCRecord(RFID_DN_HANDLE hTagReport, BYTE *date, DWORD *inPC, DWORD *outPC);
RFID_API err_t   LSG_ParseRealtimePCRecord(RFID_DN_HANDLE hTagReport, BYTE *datetime, BYTE *dir, DWORD *PC);
RFID_API err_t  LSG_InitPC(RFID_READER_HANDLE hr, BYTE type, DWORD inPC, DWORD outPC);
RFID_API err_t  LSG_Alaram(RFID_READER_HANDLE hr, BYTE gid);

RFID_API err_t LSG_FetchPCFromGate(RFID_READER_HANDLE hr, BYTE option, DWORD *pcInTotal, DWORD*pcOutTotal, DWORD*pcInDay, DWORD*pcOutDay);

RFID_API err_t LSG_SetAtmosphereLight(RFID_READER_HANDLE hr, BYTE sid, BYTE id, BYTE type, DWORD v, WORD FLASH_AT, WORD FLASH_DT);


RFID_API err_t BookShelf_SetLID(RFID_READER_HANDLE hr, BYTE lid);
RFID_API err_t BookShelf_SetLSN(RFID_READER_HANDLE hr, BYTE *lsn, BYTE len);
RFID_API err_t BookShelf_GetOnlineStatus(RFID_READER_HANDLE hr, BOOL *sta);
RFID_API err_t BookShelf_SetLayerParams(RFID_READER_HANDLE hr, RFID_DN_HANDLE params);
RFID_API err_t BookShelf_SetLayerLed(RFID_READER_HANDLE hr, RFID_DN_HANDLE params);

RFID_API RFID_DN_HANDLE BookShelf_CreateLayerParamsManager();
RFID_API RFID_DN_HANDLE BookShelf_CreateLayerParams(int offset, BYTE *data, BYTE len);
RFID_API err_t BookShelf_AddLayerParams(RFID_DN_HANDLE layerParamsManager, RFID_DN_HANDLE layerParam);

RFID_API err_t BookShelf_DestoryLayerParamsManager(RFID_DN_HANDLE layerParamsManager);


RFID_API RFID_DN_HANDLE BookShelf_CreateLedControlManager();
RFID_API RFID_DN_HANDLE BookShelf_CreateLedControl(int id, int type, DWORD activeTime, WORD flashAT, WORD flashDT);
RFID_API err_t BookShelf_AddLedControl(RFID_DN_HANDLE ledManager, RFID_DN_HANDLE ledControl);

RFID_API err_t BookShelf_DestoryLedControlManager(RFID_DN_HANDLE ledManager);

RFID_API err_t BookShelf_GetIRSta(RFID_READER_HANDLE hr, BYTE *sta);


RFID_API err_t LSC100_SetLayerLed(RFID_READER_HANDLE hr, int layid, RFID_DN_HANDLE params);

RFID_API err_t LSC100_Inventory(RFID_READER_HANDLE hr, BYTE opt, BYTE *lays, BYTE laycnt, WORD startPos, BYTE readLen, int timeout);

RFID_API err_t LSC100_ParseReport(RFID_HANDLE hReport, BYTE *type, BYTE *layid, WORD *rssi, BYTE *uid, BYTE *uidlen, BYTE *barcode, BYTE *barcodeLen);

RFID_API err_t LSC100_GetIRSta(RFID_READER_HANDLE hr, BYTE lid, BYTE *sta);

RFID_API err_t LSC100_GetLayerInfor(RFID_READER_HANDLE hr, int lid, LPTSTR buffer, DWORD *nSize/* buffer size in character */); //获取层控制器信息;

RFID_API err_t LSC100_SetOutput(RFID_READER_HANDLE hr, RFID_DN_HANDLE handle);

RFID_API err_t LSC100_DiagnosisBookShelf(RFID_READER_HANDLE hr, DWORD *flag);

RFID_API err_t LSC100_SystemReset(RFID_READER_HANDLE hr, BYTE flag);

RFID_API err_t RDR_GetAntennaSWR(RFID_READER_HANDLE hr, BYTE AntennaCount, BYTE AntennaID[], BYTE sta[], DWORD swr[]);

RFID_API err_t LSC100_GetLEDControlInfo(RFID_READER_HANDLE hr, BYTE * pAddr, BYTE* pDisp);

RFID_API err_t LSC100_SetDispText(RFID_READER_HANDLE hr, BYTE cid, BYTE sid, BYTE option, WORD dispTime, BYTE *pText, BYTE textLen);


RFID_API err_t LSC100_LayerWriteAFIEas(RFID_READER_HANDLE hr, BYTE lid, BOOL writeAfi, BOOL writeEAS, BYTE afiVal, BOOL EasEnable);

/*2020-08-28 添加RD5200 /RD2100 /M22 读卡器开始支持*/
/* 获取设备硬件唯一识别信息*/
RFID_API err_t RDR_GetDeviceUniqueID(RFID_READER_HANDLE hr, BYTE *pHUIDData, BYTE *nSize);
/* 更新用户设备数字签名*/
RFID_API err_t RDR_UpdateUserSignature(RFID_READER_HANDLE hr, BYTE *pSig, BYTE nLen);
/* 读用户设备数字签名*/
RFID_API err_t RDR_ReadUserSignature(RFID_READER_HANDLE hr, BYTE *pSig, BYTE *nSize);
/*2020-08-28 完成*/


RFID_API err_t LSG_GetIRSta(RFID_READER_HANDLE hr, BYTE sid, DWORD *ir_tri_cnt, BYTE *ir_num);
RFID_API err_t LSG_GetIRCoverSta(RFID_READER_HANDLE hr, BYTE * ir_num, BYTE * irCoverBitMask);

RFID_API err_t LSG_GetIRTriggerCounter(RFID_READER_HANDLE hr, BYTE sid, DWORD *ir_tri_cnt, BYTE *ir_num);
RFID_API err_t LSG_GetIRCurrentSta(RFID_READER_HANDLE hr, BYTE * ir_num, BYTE * irCoverBitMask);

RFID_API err_t LSG_DiagnosisFlow(RFID_READER_HANDLE hr, BYTE sid, DWORD *inflow, DWORD *outflow);


RFID_API err_t LSG_GetDetectStatus(RFID_READER_HANDLE hr, BYTE *State);
RFID_API err_t LSG_StartDetect(RFID_READER_HANDLE hr, BYTE DetectNum);


RFID_API err_t  PDA_GetScanKeyState(RFID_READER_HANDLE hr, BYTE * flag);
RFID_API err_t  PDA_LowPowerConsumption(RFID_READER_HANDLE hr, BYTE *flag);
RFID_API err_t  PDA_GetDeviceStatus(RFID_READER_HANDLE hr, BYTE *DeviceMode, BYTE * TagType);


RFID_API err_t  PDA_ParseUHFRecord(RFID_DN_HANDLE hReport, BYTE *flag, BYTE *pDatas, DWORD *pDATALen);
RFID_API err_t  PDA_ParseHFRecord(RFID_DN_HANDLE hReport, BYTE *flag, BYTE *pDatas, DWORD *pDATALen);
RFID_API err_t  PDA_ParseQRCodeRecord(RFID_DN_HANDLE hReport, BYTE *pData, DWORD *len);
RFID_API err_t  PDA_SetHostMode(RFID_READER_HANDLE hr);
RFID_API err_t  PDA_SetActiveMode(RFID_READER_HANDLE hr);



RFID_API err_t Bookcase_SetBoxAntennas(RFID_READER_HANDLE hr, BYTE boxNo, BYTE *ant, BYTE antLen);
RFID_API RFID_DN_HANDLE  Bookcase_CreateTagRecordSet(void);
RFID_API err_t  Bookcase_AddTagToRecordSet(RFID_DN_HANDLE hTagSet, BYTE boxNo, BYTE * id, DWORD idLen);
RFID_API err_t  Bookcase_DownloadTagsToBuffer(RFID_READER_HANDLE hr, RFID_DN_HANDLE hTagSet);
RFID_API RFID_DN_HANDLE Bookcase_GetTagReport(RFID_READER_HANDLE hr, BYTE mode, BYTE seek);
RFID_API err_t Bookcase_ParseTagReport(RFID_READER_HANDLE hr, RFID_DN_HANDLE dn, BYTE *boxNo, BYTE tagid[], DWORD *len);
RFID_API err_t Bookcase_Inventory(RFID_READER_HANDLE hr, BOOLEAN isBookOnshelf, BYTE boxid);
RFID_API err_t Bookcase_SubmitInventoryResult(RFID_READER_HANDLE hr);



RFID_API err_t  RDR_Active_Upload_Start(RFID_READER_HANDLE hr, BOOLEAN sendtick);
RFID_API err_t  RDR_Active_Upload_Stop(RFID_READER_HANDLE hr);




RFID_API err_t JD100_Inventory(RFID_READER_HANDLE hr, BYTE opt, RFID_DN_HANDLE hGroupManager, BYTE *sequencyID, BYTE sequencyIDLen, WORD startPos, BYTE readLen, DWORD timeout);


RFID_API err_t JD_ParseReport(RFID_HANDLE hReport, BYTE *addr, BYTE *flag, BYTE * error, BYTE *uid, BYTE *uidlen, BYTE *barcode, BYTE *barcodeLen);
RFID_API err_t JD_SearchReader(RFID_READER_HANDLE hr, BYTE opt, DWORD MaxTimeout);
RFID_API RFID_DN_HANDLE JD_FetchSearchReport(RFID_READER_HANDLE hr, BYTE seek);
RFID_API err_t  JD_ParseSearchReport(RFID_DN_HANDLE hReport, BYTE *RSN, BYTE *RSNLEN, BYTE *RID, BYTE *AID, BYTE *AIDLEN );
RFID_API err_t  JD_SetRID(RFID_READER_HANDLE hr, BYTE* pRSN, BYTE RSNLen, BYTE opt, BYTE RID, BYTE *pAID, BYTE AIDLen);
RFID_API err_t  JD_ControlLightByRSN(RFID_READER_HANDLE hr, BYTE* pRSN, BYTE RSNLen, BYTE action, BYTE  Second);


RFID_API RFID_DN_HANDLE JD_CreateLedControlManager();
RFID_API RFID_DN_HANDLE JD_CreateLedControl(int id, int type, DWORD activeTime, WORD flashAT, WORD flashDT);
RFID_API err_t JD_AddLedControl(RFID_DN_HANDLE ledManager, RFID_DN_HANDLE ledControl);
RFID_API err_t JD_DestoryLedControlManager(RFID_DN_HANDLE ledManager);
RFID_API err_t JD_ControlLedByRID(RFID_READER_HANDLE hr, int rid, RFID_DN_HANDLE params);
RFID_API err_t JD_GetReaderOfflineSta(RFID_READER_HANDLE hr, BYTE * readerSta, WORD * len);


RFID_API RFID_DN_HANDLE JD100_CreateGroupManager();
RFID_API RFID_DN_HANDLE  JD100_CreateGroup(int gid, BYTE *ids, DWORD idlen);
RFID_API err_t  JD100_AddGroupToGroupManager(RFID_DN_HANDLE hManager, RFID_DN_HANDLE hGroup);
RFID_API void JD100_DestroyGroupManager(RFID_DN_HANDLE hManager);

RFID_API DWORD EnumIP();
RFID_API err_t IP_GetEnumItem(DWORD indx, BYTE infType, LPTSTR infBuffer, DWORD *nSize);
/* 解析中大功率读卡缓冲模式的数据 */
RFID_API err_t RDR_ParseBufModeReport(RFID_DN_HANDLE hTagReport, DWORD * timestamp, DWORD * datFlag, BYTE *uidBuf, DWORD *nSizeUidBuf/*输入缓冲区大小，输出写入大小*/, BYTE * blkDatBuf, DWORD * uSizeBlkDatBuf/*输入缓冲区大小，输出写入大小*/, BYTE *ant, WORD *inputSta);
/* 检测PICC 是否还存在的函数 */
RFID_API RFID_DN_HANDLE RDR_CreateCheckExistTagsSet();
RFID_API err_t RDR_AddCheckExistTag(RFID_DN_HANDLE hTagsSet, BYTE antCnt, BYTE ants[], BYTE ulen, BYTE uid[]);
RFID_API err_t RDR_PICC_CheckTagExist(RFID_READER_HANDLE hr, RFID_DN_HANDLE tags);
RFID_API err_t RDR_GetCheckTagExistResult(RFID_DN_HANDLE hTagsSet, DWORD idx /*标签加入的索引号，0表示第一张 */, BOOLEAN *pFound);

/*获取子模块设备信息*/
RFID_API err_t RDR_GetModules(RFID_READER_HANDLE hr, BYTE* indexes, BYTE* vers, BYTE* types, BYTE* sns, BYTE* count);


/* --------------------------- LED显示屏 --------------------------- */
//创建 屏幕区域
RFID_API err_t LEDScreen_create_area(RFID_READER_HANDLE hr, int area_id, int pointx, int pointy, int width, int height, int action,
                                     int speed, int hold_time, int colour, int fsize, int hAlign, int vAlign, const char* area_content);
//删除 屏幕区域
RFID_API err_t LEDScreen_delete_area(RFID_READER_HANDLE hr, int area_id);
//屏幕区域 输入文本显示
RFID_API err_t LEDScreen_print_text(RFID_READER_HANDLE hr, int area_id, const char* area_content, int action, int speed);

/* --------------------------- 灯控 --------------------------- */
//打开  灭菌灯 light_type=1/ 照明灯light_type=2
RFID_API err_t Light_turn_on(RFID_READER_HANDLE hr,int light_type);
//关闭 灭菌灯 light_type=1/ 照明灯light_type=2
RFID_API err_t Light_turn_off(RFID_READER_HANDLE hr,int light_type);

/* --------------------------- 锁控 --------------------------- */
//开锁
RFID_API err_t Lock_unlock(RFID_READER_HANDLE hr, int boardNum, int lockNum, int timeout);
//读取锁状态
RFID_API err_t Lock_read_lock(RFID_READER_HANDLE hr, int boardNum, int lockNum, int timeout);

/* -------------------------- 外设控制板(初始用于SSK502设备) ---------------- */
RFID_API err_t CtrlBoard_LockControl(RFID_READER_HANDLE hr,BYTE lockType,DWORD boardAddr, DWORD param);

RFID_API err_t CtrlBoard_LightControl(RFID_READER_HANDLE hr, DWORD boardAddr, DWORD mask, DWORD status);

RFID_API err_t CtrlBoard_GetLockStatus(RFID_READER_HANDLE hr,BYTE lockType, DWORD boardAddr, DWORD lockId, BYTE *status);

RFID_API err_t CtrlBoard_GetIRStatus(RFID_READER_HANDLE hr,DWORD boardAddr,DWORD* ir_mask,DWORD* ir_status);

RFID_API err_t CtrlBoard_GetDeviceInfo(RFID_READER_HANDLE hr,BYTE type,LPTSTR info, DWORD* nSize);

/* Output */
RFID_API RFID_DN_HANDLE CtrlBoard_CreateSetOutputOperations();

/* Output mode: 0:use reader default setting,0:unchanged, 1:on,2:off,3:flash */
RFID_API err_t CtrlBoard_AddOneOutputOperation(RFID_DN_HANDLE hOperas, BYTE outNo, BYTE outMode, DWORD outFrequency,
                                               DWORD outActiveDuration, DWORD outInactiveDuration);
RFID_API err_t CtrlBoard_SetOutput(RFID_READER_HANDLE hr, RFID_DN_HANDLE outputOpers);
/* Atmosphere */
RFID_API err_t CtrlBoard_AddAtmosphereOperation(RFID_DN_HANDLE hOperas, BYTE outMode, DWORD outFrequency, DWORD outActiveDuration,
                                                DWORD outInactiveDuration, BYTE cnt, BYTE id, BYTE pwn);
RFID_API err_t CtrlBoard_SetAtmosphere(RFID_READER_HANDLE hr, RFID_DN_HANDLE outputOpers);

RFID_API err_t CtrlBoard_MotorOperation(RFID_READER_HANDLE hr, DWORD mode, DWORD keepTime);

/* --------------------------- LSG --------------------------- */

RFID_API err_t LSG_TcpSend(RFID_READER_HANDLE hr, BYTE * pData, WORD pLen);

RFID_API err_t LSG_TcpRecv(RFID_READER_HANDLE hr, BYTE *pRecvBuff, WORD buffLen, WORD* lengthOfRead);

/* --------------------------- G301 --------------------------- */


RFID_API err_t G310_SetAlarm(RFID_READER_HANDLE hr, BYTE out_sel, DWORD V, WORD flash_at, WORD flash_dt);

RFID_API err_t G310_SetLightAndBuzzer(RFID_READER_HANDLE hr, BYTE sid, BYTE id, BYTE type, DWORD v, WORD FLASH_AT, WORD FLASH_DT);

RFID_API err_t G310_ParseTagDataReport(RFID_READER_HANDLE hr, RFID_DN_HANDLE hTagReport, BYTE* uid_len, BYTE  uid[], BYTE* db_len, BYTE db_data[], BYTE time[],BYTE* direction);

RFID_API err_t G310_ParseTagDataReportEx(RFID_READER_HANDLE hr, RFID_DN_HANDLE hTagReport, BYTE* uid_len, BYTE  uid[],
                                         BYTE* db_len, BYTE db_data[], BYTE time[],BYTE* direction,BYTE* channel);

RFID_API err_t G310_GetInventoryReport(RFID_READER_HANDLE hr, BYTE flash);

RFID_API RFID_DN_HANDLE Gate_CreateLCDControlUpdateOperation();

RFID_API err_t Gate_AddLCDControlWriteStringVal(RFID_DN_HANDLE hOperas,BYTE id, LPCTSTR value);

RFID_API err_t Gate_UpdateLCDControlValue(RFID_READER_HANDLE hr, RFID_DN_HANDLE hOperas);

RFID_API err_t RDR_Enum_variable_submodule(RFID_READER_HANDLE hr, BYTE *num, BYTE *SID, BYTE *TYPE);

}//namespace end

#if __cplusplus
}
#endif

